import request from '@/utils/request'
import { getToken as getCookieToken } from '@/utils/auth'
/**
 * 获取备份策略信息列表
 * @param {string}
 */
export function findBackupPolicyPage(query) {
  return request({
    url: '/monitor/backuppolicy/findBackupPolicyPage',
    method: 'get',
    params: query
  })
}
/**
 * 获取数据源列表
 * @param {string}
 */
export function getDatasourceList(query) {
  return request({
    url: '/monitor/datasource/getDatasourceList',
    method: 'get',
    params: query
  })
}
/**
 * 获取备份日志信息列表
 * @param {string}
 */
export function findBackupLogPage(query) {
  return request({
    url: '/monitor/backuplog/findBackupLogPage',
    method: 'get',
    params: query
  })
}
/**
 * 保存或修改数据源
 * @param {string}
 */
export function saveOrUpdateDatasource(query) {
  return request({
    url: '/monitor/datasource/saveOrUpdateDatasource',
    method: 'get',
    params: query
  })
}
/**
 * 保存或修改备份策略信息
 * @param {string}
 */
export function saveOrUpdateBackupPolicy(query) {
  return request({
    url: '/monitor/backuppolicy/saveOrUpdateBackupPolicy',
    method: 'get',
    params: query
  })
}
/**
 * 通过id删除备份策略信息
 * @param {string}
 */
export function deleteBackupPolicyById(query) {
  return request({
    url: '/monitor/backuppolicy/deleteBackupPolicyById',
    method: 'get',
    params: query
  })
}
/**
 * 通过id获取备份策略信息
 * @param {string}
 */
export function findBackupPolicyById(query) {
  return request({
    url: '/monitor/backuppolicy/findBackupPolicyById',
    method: 'get',
    params: query
  })
}
/**
 * 通过id获取备份详情信息
 * @param {string}
 */
export function findBackupInfoById(query) {
  return request({
    url: '/monitor/backupinfo/findBackupInfoById',
    method: 'get',
    params: query
  })
}
/**
 * 数据备份接口
 * @param {string}
 */
export function backup(query) {
  return request({
    url: '/monitor/monitor/backupNew',
    method: 'get',
    params: query
  })
}
/**
 * 获取备份详情信息列表
 * @param {string}
 */
export function findBackupInfoPage(query) {
  return request({
    url: '/monitor/backupinfo/findBackupInfoPage',
    method: 'get',
    params: query
  })
}
/**
 * 通过id获取备份日志信息
 * @param {string}
 */
export function findBackupLogById(query) {
  return request({
    url: '/monitor/backuplog/findBackupLogById',
    method: 'get',
    params: query
  })
}
/**
 * 备份回复功能
 * @param {string}
 */
export function restore(query) {
  return request({
    url: '/monitor/monitor/restoreNew?id=' + query,
    method: 'get'
  })
}
/**
 * 数据恢复接口
 * @param {string}
 */
export function getCollection(query) {
  return request({
    url: '/monitor/monitor/getCollection',
    method: 'get',
    params: query
  })
}
/**
 * 通过id获取数据源
 * @param {string}
 */
export function findDatasourceById(query) {
  return request({
    url: '/monitor/datasource/findDatasourceById',
    method: 'get',
    params: query
  })
}
/**
 * 数据源测试
 * @param {string}
 */
export function testDatasource(query) {
  return request({
    url: '/monitor/monitor/testDatasource',
    method: 'get',
    params: query
  })
}
/**
 * 上传下载测试接口
 * @param {string}
 */
export function downLoad(query) {
  return request({
    url: '/monitor/monitor/downLoad?id=' + query,
    method: 'get',
    headers: {
      'Content-Type': 'application/octet-stream' // 流
    },
    'Content-Type': 'application/octet-stream', // 流
    responseType: 'blob',
    params: {
      access_token: getCookieToken()
    }
  })
}
/**
 * 恢复详情信息列表
 * @param {string}
 */
export function findInfoPage(query) {
  return request({
    url: '/monitor/restoreinfo/findInfoPage',
    method: 'get',
    params: query
  })
}
/**
 * 获取任务信息
 * @param {string}
 */
export function getStatus(query) {
  return request({
    url: '/monitor/monitor/getStatus?id=' + query,
    method: 'get',
    params: query
  })
}
/**
 * 获取任务信息
 * @param {string}
 */
export function getRestoreStatus(query) {
  return request({
    url: '/monitor/monitor/getRestoreTaskStatus?id=' + query,
    method: 'get',
    params: query
  })
}
/**
 * 通过id删除数据源
 * @param {string}
 */
export function deleteDatasourceById(query) {
  return request({
    url: '/monitor/datasource/deleteDatasourceById',
    method: 'get',
    params: query
  })
}
